#ifndef MESSAGEEVENT_H_
#define MESSAGEEVENT_H_


#include "../Buddy.h"
#include <wx/event.h>
#include "../database/DBType.h"

namespace Impp
{

enum MessageEventType{
	MESSAGE_EVENT_NORMAL_MESSAGE = 1 ,
	MESSAGE_EVENT_OFFLINE_MESSAGE = 2,
	MESSAGE_EVENT_URL_MESSAGE = 3
};

class MessageEvent : public wxNotifyEvent
{
private:
	Buddy* buddy;
	wxDateTime time;
	wxString msg;
	db_id historyId;
	int/*<MessageEventType>*/ messageEventType;

public:
	MessageEvent(Buddy* & sender, const wxDateTime  & time, const wxString msg, db_id & historyId, int/*<MessageEventType>*/ messageEventType, wxEventType eventType = wxEVT_NULL, int id = 0);
	virtual ~MessageEvent();

	virtual wxEvent* Clone()const;

	Buddy* getBuddy();
	wxDateTime getTime();
	wxString getMessage();
	db_id getHistoryId();
	int/*<MessageEventType>*/ getMessageEventType();

};


// ein Typedef auf die entsprechenden EventHandler
typedef void(wxEvtHandler::*MessageEventFunction)(MessageEvent&);

// wxWidgets den neuen Event mitteilen
BEGIN_DECLARE_EVENT_TYPES()
  DECLARE_EVENT_TYPE(EVT_MESSAGE_IN, -1)
  DECLARE_EVENT_TYPE(EVT_MESSAGE_OUT, -1)
END_DECLARE_EVENT_TYPES()

// dieses #define sorgt daf�r das man den Event �ber den Makro EventTable einbinden kann
#define EVT_MESSAGE_MACRO(id, fn) DECLARE_EVENT_TABLE_ENTRY(               \
        EVT_MESSAGE, id, -1, (wxObjectEventFunction)               \
        (wxEventFunction)(MessageEventFunction) & fn,                             \
        (wxObject*) NULL),

// dieses #define sorgt daf�r das man den Event auch �ber Connect verbinden kann
#define MessageEventHandler(func)                                                 \
        (wxObjectEventFunction)                                                \
        (wxEventFunction)wxStaticCastEvent(MessageEventFunction, &func)
}

#endif /*MESSAGEEVENT_H_*/
